<?php

class Link extends Mysql {
	public function __construct() {
		parent::__construct();
	}
	/**
	 * 根据文章type查询所有文章 分页
	 * 2012-5-2 上午10:49:26
	 * Xewee.Zhiwei.Wang
	 */
	public function query($articleTypeId, $pageIndex, $pageSize) {
		$sql = "";
		if (empty($articleTypeId)) {
			$sql = "select * from link LIMIT $pageIndex * $pageSize $pageSize;";
		}
		else {
			$sql = "select * from link where typeId = $articleTypeId LIMIT $pageIndex * $pageSize $pageSize;";
		}
		$rows = $this->exec_query($sql);
		return $rows;
	}
	
	public function add($id, $title, $content, $adminId, $time, $typeId, $deleted) {
		$sql = "insert into article(title, content, adminId, time, typeId, deleted) values ($title, $content, $adminId, $time, $typeId, $deleted);";
		return $this->exec_update($sql);
	}
	
	public function delete($id) {
		$sql = "update article set deleted = '1' where id = $id;";
		return $this->exec_update($sql);
	}
	
	public function update($id, $title, $content, $adminId, $time, $typeId, $deleted) {
		$sql = "update article set 
				title = $title, 
				content = $content, 
				adminId = $adminId, 
				time = $time, 
				typeId = $typeId, 
				deleted = $deleted 
			where id = $id;";
		return $this->exec_update($sql);
	}
}

?>